<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   从零开始 Python 微信公众号开发  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/24635.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466454806: Accept with keywords: (title(0.25):Python,公众,社区,数盟, topn(0.3):账号,数盟,开源,过程,结果,Python,东西,关键字,源码,文章,类型,服务器,数据,图片,编程,用户,公众,内容,链接,功能,编程语言,新建,部分,代码,平台,爬虫,字段,专栏,消息,文本).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    从零开始 Python 微信公众号开发
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    从零开始 Python 微信公众号开发 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,66] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/devl">
       编程语言
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/24635.html">
          从零开始 Python 微信公众号开发
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          242 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/devl" rel="category tag">
          编程语言
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        作者：段小草 知乎专栏 原文链接：https://zhuanlan.zhihu.com/p/21354943
       </p>
       <div>
        <p>
         前些日子在知乎上看到了一篇文章
         <a class="internal" href="https://zhuanlan.zhihu.com/p/21284127">
          Python公众号开发部分代码开源 – 学习编程 – 知乎专栏
         </a>
         。文章里倒是给出了一些可以用的源码，可惜没具体说怎么部署到自己的服务器和公众号，也没有对源码进行应有的解释，自己摸索了几天以后算是成功搭好了一个简单的 python 微信公众号后台，对刚开始的源码进行了一些改善，正好专栏也很久没更新了，写一篇记录一下过程吧。
         <br/>
         主要工具：SAE+微信公众号+Git+Python本地环境（最好已经安装好了Git并配置好了Python IDE，比如Pycharm）
        </p>
        <h2>
         1. 工欲善其事
        </h2>
        <p>
         首先要简单介绍一下一些准备工作。
        </p>
        <p>
         1.1 微信公众号
        </p>
        <p>
         第一步是要注册一个个人微信公众号（个人账号不支持认证），按照
         <a class=" external" href="https://link.zhihu.com/?target=https%3A//mp.weixin.qq.com/" rel="nofollow noreferrer" target="_blank">
          <span class="invisible">
           https://
          </span>
          <span class="visible">
           mp.weixin.qq.com/
          </span>
          <i class="icon-external">
          </i>
         </a>
         给出的过程依次填写需要的信息就可以完成申请，如果已有账号的话可以直接登录。
        </p>
        <p>
         登录以后可以看到左边栏中的自动回复功能：
        </p>
        <p>
         <img src="https://pic4.zhimg.com/1e36e7e18df9d9f4a23d250a42872e07_b.png"/>
         在一般的使用中，我们可以通过设置关键字实现一些基本的自动回复功能，但是这样的关键字回复远远不能满足我们的实际需求，比如我们要实现一个查快递的功能，必然是要通过调用快递接口对不同用户的不同输入给出不同的输出结果，在这样的情况下关键字回复就显得很鸡肋了。于是我们选择了开发者模式。
        </p>
        <p>
         <img src="https://pic4.zhimg.com/81448ad5279be34587098212d1ba6987_b.png"/>
         在基本配置中，我们只需要修改URL、Token和EncodingAESKey三项配置即可，由于我们现在还没有配好自己的服务器，微信公众号这边的设置到这里暂停，等我们有了服务器获取了地址以后回来填写就可以了。
        </p>
        <p>
         1.2 SAE
        </p>
        <p>
         这次我们使用新浪云作为我们的服务器，注册登录
         <a class=" external" href="https://link.zhihu.com/?target=https%3A//www.sinacloud.com" rel="nofollow noreferrer" target="_blank">
          <span class="invisible">
           https://www.
          </span>
          <span class="visible">
           sinacloud.com
          </span>
          <i class="icon-external">
          </i>
         </a>
         ，新用户会有一定的优惠云豆，老用户充个十块也足够我们完成很多学习任务了。
        </p>
        <p>
         选择云应用，进入控制台后创建新应用。
        </p>
        <p>
         <img src="https://pic3.zhimg.com/bb89267fe7e6d431dcdbc60d8f2e52ce_b.png"/>
         输入二级域名和应用名称（必填项），在下面的运行环境中选择 Python2.7 – 空应用。
        </p>
        <p>
         <img src="https://pic3.zhimg.com/0fb7c2c727d69890f8a3bb02dbd5db96_b.png"/>
         成功创建应用后，会获得相应的一些配置数据和密钥，当然这些内容这次用不到，主要用到的就是登陆账号和安全密码。
        </p>
        <p>
         <img src="https://pic2.zhimg.com/cf532f65f65e5aac25afd111d81a2571_b.png"/>
         SAE平台的代码版本控制分为Git和SVN，两者可以自由选择，这次我们选择使用Git进行代码的上传操作。
        </p>
        <p>
         <img src="https://pic4.zhimg.com/4eb5bdb84f0d6a4c69e27a32946d176f_b.png"/>
         1.3 Git
        </p>
        <p>
         对于Windows系统，电脑上如果安装了 Github Desktop 的话，应该就自带了 Git Bash 和 Git Shell 这样的工具，如果之前没有安装过 Git 相关的软件，可以自行搜索 Git 以后安装 Git for Windows。
        </p>
        <p>
         Git 刚接触时可能很复杂，用起来功能很强大但繁琐，初学者可能绕来绕去就绕晕了，但是在这次的搭建过程中我们其实只需要用到四五条极为简单的命令即可，所以完全无需担心 Git ，也不要让 Git 成为你拒绝迈出第一步的障碍。（关于 SAE 的代码管理，详见
         <a class=" external" href="https://link.zhihu.com/?target=https%3A//www.sinacloud.com/doc/sae/tutorial/code-deploy.html%23git" rel="nofollow noreferrer" target="_blank">
          <span class="invisible">
           https://www.
          </span>
          <span class="visible">
           sinacloud.com/doc/sae/t
          </span>
          <span class="invisible">
           utorial/code-deploy.html#git
          </span>
          <i class="icon-external">
          </i>
         </a>
         ）
        </p>
        <p>
         下面就让我们进入到真正的开发阶段吧！
        </p>
        <h2>
         2. 捅破窗户纸
        </h2>
        <p>
         犹记得我大一的时候公众号刚刚兴起，当时我还兴致冲冲地注册了账号，设置了一大堆的关键字自动回复，坚持了数天的图文消息推送，但是当我真正开始研究开发者模式，真正想去调用一些接口时却发现，好像自己该学的也都学了，该用的也都用过，就是串不到一起去，做不出想要的东西来（当时用的好像还是 PHP ），后面一直搁置了公众号这样的东西，一下子就拖到了现在。这两天试了一下 Python 服务器的配置，发现完全就是一层窗户纸，其实一捅就破，完全没有当初的纠结和复杂了。
        </p>
        <p>
         2.1 服务器配置和 Token 认证
        </p>
        <p>
         由于我们之前在 SAE 平台创建的是空应用，所以我们需要做一些基础的配置工作。这次我们选择使用 web.py （Python 2.7）来进行服务器搭建，如果本地没有 web.py 库的话可以通过 pip 命令进行安装（pip install web.py）。
        </p>
        <p>
         之后我们需要创建一个项目，并编辑如下的基本代码。
        </p>
        <p>
         config.yaml
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a4e500158633" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            name: wxpytest
version: 1

libraries:
- name: webpy
  version: "0.36"

- name: lxml
  version: "2.3.4"

...
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a4e500158633-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a4e500158633-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a4e500158633-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a4e500158633-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a4e500158633-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a4e500158633-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a4e500158633-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a4e500158633-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a4e500158633-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a4e500158633-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a4e500158633-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a4e500158633-12">
                 12
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a4e500158633-1">
                 <span class="crayon-v">
                  name
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  wxpytest
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a4e500158633-2">
                 <span class="crayon-v">
                  version
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a4e500158633-3">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a4e500158633-4">
                 <span class="crayon-v">
                  libraries
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a4e500158633-5">
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  name
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  webpy
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a4e500158633-6">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  version
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  "0.36"
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a4e500158633-7">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a4e500158633-8">
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  name
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  lxml
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a4e500158633-9">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  version
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  "2.3.4"
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a4e500158633-10">
                </div>
                <div class="crayon-line" id="crayon-5768530f61a4e500158633-11">
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a4e500158633-12">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0106 seconds] -->
        </div>
        <p>
         index.wsgi
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a5f746134597" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            # coding: UTF-8
import os
import sae
import web

from weixinInterface import WeixinInterface

urls = (
'/weixin','WeixinInterface'
)

app_root = os.path.dirname(__file__)
templates_root = os.path.join(app_root, 'templates')
render = web.template.render(templates_root)

app = web.application(urls, globals()).wsgifunc()        
application = sae.create_wsgi_app(app)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-15">
                 15
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-16">
                 16
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a5f746134597-17">
                 17
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a5f746134597-18">
                 18
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-1">
                 <span class="crayon-p">
                  # coding: UTF-8
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-2">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  os
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-3">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  sae
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-4">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  web
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-5">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-6">
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  weixinInterface
                 </span>
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  WeixinInterface
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-7">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-8">
                 <span class="crayon-v">
                  urls
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-9">
                 <span class="crayon-s">
                  '/weixin'
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-s">
                  'WeixinInterface'
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-10">
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-11">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-12">
                 <span class="crayon-v">
                  app_root
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  os
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  path
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  dirname
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  __file__
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-13">
                 <span class="crayon-v">
                  templates_root
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  os
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  path
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  join
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  app_root
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'templates'
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-14">
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  template
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  render
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  templates_root
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-15">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-16">
                 <span class="crayon-v">
                  app
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  application
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  urls
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  globals
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  wsgifunc
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a5f746134597-17">
                 <span class="crayon-v">
                  application
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sae
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  create_wsgi_app
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  app
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a5f746134597-18">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0146 seconds] -->
        </div>
        <p>
         这两部分是 web.py 的基础配置文件，之后我们需要开始编写实现微信公众平台功能的代码。
        </p>
        <p>
         新建weixinInterface.py
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a67478433515" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            # -*- coding: utf-8 -*-
import hashlib
import web
import lxml
import time
import os


class WeixinInterface:

    def __init__(self):
        self.app_root = os.path.dirname(__file__)
        self.templates_root = os.path.join(self.app_root, 'templates')
        self.render = web.template.render(self.templates_root)

    def GET(self):
        #获取输入参数
        data = web.input()
        signature=data.signature
        timestamp=data.timestamp
        nonce=data.nonce
        echostr = data.echostr
        #自己的token
        token="token" #这里改写你在微信公众平台里输入的token
        #字典序排序
        list=[token,timestamp,nonce]
        list.sort()
        sha1=hashlib.sha1()
        map(sha1.update,list)
        hashcode=sha1.hexdigest()
        #sha1加密算法

        #如果是来自微信的请求，则回复echostr
        if hashcode == signature:
            return echostr
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-15">
                 15
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-16">
                 16
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-17">
                 17
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-18">
                 18
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-19">
                 19
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-20">
                 20
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-21">
                 21
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-22">
                 22
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-23">
                 23
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-24">
                 24
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-25">
                 25
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-26">
                 26
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-27">
                 27
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-28">
                 28
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-29">
                 29
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-30">
                 30
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-31">
                 31
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-32">
                 32
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-33">
                 33
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-34">
                 34
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a67478433515-35">
                 35
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a67478433515-36">
                 36
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a67478433515-1">
                 <span class="crayon-p">
                  # -*- coding: utf-8 -*-
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-2">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  hashlib
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-3">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  web
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-4">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  lxml
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-5">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-6">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  os
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-7">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-8">
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-9">
                 <span class="crayon-t">
                  class
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  WeixinInterface
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-10">
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  __init__
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  app_root
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  os
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  path
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  dirname
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  __file__
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-13">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  templates_root
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  os
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  path
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  join
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  app_root
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'templates'
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-14">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  template
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  render
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  templates_root
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-15">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-16">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  GET
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-17">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #获取输入参数
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-18">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  input
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-19">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  signature
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  signature
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-20">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  timestamp
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  timestamp
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-21">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  nonce
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  nonce
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-22">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  echostr
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  echostr
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-23">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #自己的token
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-24">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  token
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-s">
                  "token"
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #这里改写你在微信公众平台里输入的token
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-25">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #字典序排序
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-26">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  list
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  token
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  timestamp
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  nonce
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-27">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  list
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  sort
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-28">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sha1
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  hashlib
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  sha1
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-29">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  map
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  sha1
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  update
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  list
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-30">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  hashcode
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  sha1
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  hexdigest
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-31">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #sha1加密算法
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-32">
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-33">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #如果是来自微信的请求，则回复echostr
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-34">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  hashcode
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  signature
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a67478433515-35">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  echostr
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a67478433515-36">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0436 seconds] -->
        </div>
        <p>
         编写好这三部分的代码后，我们就实现了最简单的微信平台认证配置，这三部分代码中需要修改的只有 token 字段，需要和你在微信平台中输入的 token 保持一致。（之后有机会再详细写具体的认证过程吧，这次只罗列一下实现过程，需要注意的是认证 token 我们只需要用 GET 方法而之后的发消息需要用 POST 方法。）
        </p>
        <p>
         这时我们需要把代码上传到 SAE 平台，然后在微信平台进行认证请求。
        </p>
        <p>
         在文件根目录右键打开 Git Bash，依次输入如下命令，过程中可能会需要输入 SAE 的用户名和安全密码，按照提示操作即可。
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a6f338432601" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            git init
git remote add sae https://git.sinacloud.com/yourapp
git add .
git commit -m 'your commit message'
git push sae master:1
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a6f338432601-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a6f338432601-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a6f338432601-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a6f338432601-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a6f338432601-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a6f338432601-6">
                 6
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a6f338432601-1">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-e">
                  init
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a6f338432601-2">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-e">
                  remote
                 </span>
                 <span class="crayon-e">
                  add
                 </span>
                 <span class="crayon-e">
                  sae
                 </span>
                 <span class="crayon-v">
                  https
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-c">
                  //git.sinacloud.com/yourapp
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a6f338432601-3">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-i">
                  add
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a6f338432601-4">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-v">
                  commit
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-i">
                  m
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'your commit message'
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a6f338432601-5">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-e">
                  push
                 </span>
                 <span class="crayon-e">
                  sae
                 </span>
                 <span class="crayon-v">
                  master
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a6f338432601-6">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0031 seconds] -->
        </div>
        <p>
         之后回到公众平台的开发者页面，填写 URL 为
         <a class=" wrap external" href="https://link.zhihu.com/?target=http%3A//XXXX.sinaapp.com/weixin" rel="nofollow noreferrer" target="_blank">
          http://xxxx.sinaapp.com/weixin
          <i class="icon-external">
          </i>
         </a>
         填写 Token 与代码中的 token 一致，EncodingAESKey 随机生成，然后点击提交认证，如果上面步骤没有操作错误，这一步就可以认证成功了。
        </p>
        <p>
         2.2 最简单的消息回复机制
        </p>
        <p>
         在微信公众号的认证完成以后，就可以针对用户的消息搞一些事情了。（消息类型开发文档详见
         <a class=" external" href="https://link.zhihu.com/?target=https%3A//mp.weixin.qq.com/wiki%3Ft%3Dresource/res_main%26id%3Dmp1421140453%26token%3D%26lang%3Dzh_CN" rel="nofollow noreferrer" target="_blank">
          <span class="invisible">
           https://
          </span>
          <span class="visible">
           mp.weixin.qq.com/wiki?
          </span>
          <span class="invisible">
           t=resource/res_main&amp;id=mp1421140453&amp;token=&amp;lang=zh_CN
          </span>
          <i class="icon-external">
          </i>
         </a>
         ）
        </p>
        <p>
         用户与公众号之间的消息交互类型分为文本、图片、语音、视频、小视频、地理位置、链接等，本文中主要会用到文本和图片两种消息类型。
        </p>
        <p>
         用户消息以 XML 形式传至我们搭建好的服务器中，我们需要解析 XML 信息，获取出需要的信息，进行处理后对用户回复结果。
        </p>
        <p>
         我们先来简单看一下文本消息和图片消息的 XML 结构。
        </p>
        <p>
         文本：
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a77834577658" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            &amp;lt;xml&amp;gt;
 &amp;lt;ToUserName&amp;gt;&amp;lt;![CDATA[toUser]]&amp;gt;&amp;lt;/ToUserName&amp;gt;
 &amp;lt;FromUserName&amp;gt;&amp;lt;![CDATA[fromUser]]&amp;gt;&amp;lt;/FromUserName&amp;gt;
 &amp;lt;CreateTime&amp;gt;1348831860&amp;lt;/CreateTime&amp;gt;
 &amp;lt;MsgType&amp;gt;&amp;lt;![CDATA[text]]&amp;gt;&amp;lt;/MsgType&amp;gt;
 &amp;lt;Content&amp;gt;&amp;lt;![CDATA[this is a test]]&amp;gt;&amp;lt;/Content&amp;gt;
 &amp;lt;MsgId&amp;gt;1234567890123456&amp;lt;/MsgId&amp;gt;
 &amp;lt;/xml&amp;gt;
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a77834577658-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a77834577658-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a77834577658-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a77834577658-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a77834577658-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a77834577658-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a77834577658-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a77834577658-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a77834577658-9">
                 9
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a77834577658-1">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a77834577658-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  ToUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  ToUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a77834577658-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  FromUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  FromUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a77834577658-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  CreateTime
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-cn">
                  1348831860
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  CreateTime
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a77834577658-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  MsgType
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  text
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  MsgType
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a77834577658-6">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  Content
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-r">
                  this
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  is
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  a
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  test
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  Content
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a77834577658-7">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  MsgId
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-cn">
                  1234567890123456
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  MsgId
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a77834577658-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a77834577658-9">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0237 seconds] -->
        </div>
        <p>
         图片：
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a7e001792935" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            &amp;lt;xml&amp;gt;
 &amp;lt;ToUserName&amp;gt;&amp;lt;![CDATA[toUser]]&amp;gt;&amp;lt;/ToUserName&amp;gt;
 &amp;lt;FromUserName&amp;gt;&amp;lt;![CDATA[fromUser]]&amp;gt;&amp;lt;/FromUserName&amp;gt;
 &amp;lt;CreateTime&amp;gt;1348831860&amp;lt;/CreateTime&amp;gt;
 &amp;lt;MsgType&amp;gt;&amp;lt;![CDATA[image]]&amp;gt;&amp;lt;/MsgType&amp;gt;
 &amp;lt;PicUrl&amp;gt;&amp;lt;![CDATA[this is a url]]&amp;gt;&amp;lt;/PicUrl&amp;gt;
 &amp;lt;MediaId&amp;gt;&amp;lt;![CDATA[media_id]]&amp;gt;&amp;lt;/MediaId&amp;gt;
 &amp;lt;MsgId&amp;gt;1234567890123456&amp;lt;/MsgId&amp;gt;
 &amp;lt;/xml&amp;gt;
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a7e001792935-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a7e001792935-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a7e001792935-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a7e001792935-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a7e001792935-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a7e001792935-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a7e001792935-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a7e001792935-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a7e001792935-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a7e001792935-10">
                 10
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a7e001792935-1">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a7e001792935-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  ToUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  ToUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a7e001792935-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  FromUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  FromUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a7e001792935-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  CreateTime
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-cn">
                  1348831860
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  CreateTime
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a7e001792935-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  MsgType
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  image
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  MsgType
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a7e001792935-6">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  PicUrl
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-r">
                  this
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  is
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  a
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  url
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  PicUrl
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a7e001792935-7">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  MediaId
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  media_id
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  MediaId
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a7e001792935-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  MsgId
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-cn">
                  1234567890123456
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  MsgId
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a7e001792935-9">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a7e001792935-10">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0212 seconds] -->
        </div>
        <p>
         可以看到，两者共有的字段为ToUserName、FromUserName、CreateTime、MsgType和MsgId，对于文本消息，我们可以通过Content字段直接提取出消息文本内容，但是对于图片消息，我们需要通过PicUrl或MediaId获取图片信息后进行处理。
        </p>
        <p>
         下面是
         <a class="internal" href="https://zhuanlan.zhihu.com/p/21284127">
          Python公众号开发部分代码开源 – 学习编程 – 知乎专栏
         </a>
         中给出的一个写法：
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a86503794017" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            def POST(self): 
    str_xml = web.data() #获得post来的数据 
    xml = etree.fromstring(str_xml)#进行XML解析 
    content=xml.find("Content").text#获得用户所输入的内容
    msgType=xml.find("MsgType").text 
    fromUser=xml.find("FromUserName").text 
    toUser=xml.find("ToUserName").text 
    if(content == u"天气"):
        pass
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a86503794017-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a86503794017-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a86503794017-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a86503794017-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a86503794017-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a86503794017-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a86503794017-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a86503794017-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a86503794017-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a86503794017-10">
                 10
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a86503794017-1">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  POST
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a86503794017-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  data
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #获得post来的数据
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a86503794017-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  etree
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  fromstring
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-p">
                  #进行XML解析
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a86503794017-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "Content"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  text
                 </span>
                 <span class="crayon-p">
                  #获得用户所输入的内容
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a86503794017-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "MsgType"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a86503794017-6">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "FromUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a86503794017-7">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "ToUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a86503794017-8">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  u
                 </span>
                 <span class="crayon-s">
                  "天气"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a86503794017-9">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  pass
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a86503794017-10">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0035 seconds] -->
        </div>
        <p>
         我并不推荐这种写法，因为在那篇文章中，作者只针对文本消息进行处理，没有实现对消息类型做相应判断，此时如果服务器接收到图片消息，content=xml.find(“Content”).text 就会执行失败，返回错误信息，导致公众号无法正常工作，所以，更好的写法是先进行消息类型判断后执行相应的操作。
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a8c270841828" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            def POST(self): 
    str_xml = web.data() #获得post来的数据 
    xml = etree.fromstring(str_xml)#进行XML解析 
    msgType=xml.find("MsgType").text 
    fromUser=xml.find("FromUserName").text 
    toUser=xml.find("ToUserName").text 
    if msgType == 'text':
        content=xml.find("Content").text
        if(content == u"天气"):
            pass
    elif msgType == 'image':
        pass
    else:
        pass
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a8c270841828-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a8c270841828-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a8c270841828-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a8c270841828-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a8c270841828-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a8c270841828-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a8c270841828-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a8c270841828-15">
                 15
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-1">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  POST
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a8c270841828-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  data
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #获得post来的数据
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  etree
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  fromstring
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-p">
                  #进行XML解析
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a8c270841828-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "MsgType"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-5">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "FromUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a8c270841828-6">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "ToUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-7">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'text'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a8c270841828-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "Content"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-9">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  u
                 </span>
                 <span class="crayon-s">
                  "天气"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a8c270841828-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  pass
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-11">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-e">
                  elif
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'image'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a8c270841828-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  pass
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-13">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  else
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a8c270841828-14">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  pass
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a8c270841828-15">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0077 seconds] -->
        </div>
        <p>
         获取到用户发送的消息后，我们需要考虑如何给用户发消息，其实并不难，我们只需要给定一个消息模板，并在相应的功能最后设置返回值即可
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a92887688184" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            return self.render.reply_text(fromUser,toUser,int(time.time()), 'you string here')
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a92887688184-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a92887688184-2">
                 2
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a92887688184-1">
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'you string here'
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a92887688184-2">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0078 seconds] -->
        </div>
        <p>
         在目录下新建 templates/reply_text.xml
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a98020167777" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            $def with (toUser,fromUser,createTime,content)
&amp;lt;xml&amp;gt;
&amp;lt;ToUserName&amp;gt;&amp;lt;![CDATA[$toUser]]&amp;gt;&amp;lt;/ToUserName&amp;gt;
&amp;lt;FromUserName&amp;gt;&amp;lt;![CDATA[$fromUser]]&amp;gt;&amp;lt;/FromUserName&amp;gt;
&amp;lt;CreateTime&amp;gt;$createTime&amp;lt;/CreateTime&amp;gt;
&amp;lt;MsgType&amp;gt;&amp;lt;![CDATA[text]]&amp;gt;&amp;lt;/MsgType&amp;gt;
&amp;lt;Content&amp;gt;&amp;lt;![CDATA[$content]]&amp;gt;&amp;lt;/Content&amp;gt;
&amp;lt;/xml&amp;gt;
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a98020167777-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a98020167777-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a98020167777-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a98020167777-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a98020167777-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a98020167777-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a98020167777-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a98020167777-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a98020167777-9">
                 9
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a98020167777-1">
                 <span class="crayon-sy">
                  $
                 </span>
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  with
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  createTime
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a98020167777-2">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a98020167777-3">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  ToUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-sy">
                  $
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  ToUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a98020167777-4">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  FromUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-sy">
                  $
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  FromUserName
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a98020167777-5">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  CreateTime
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-sy">
                  $
                 </span>
                 <span class="crayon-v">
                  createTime
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  CreateTime
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a98020167777-6">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  MsgType
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  text
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  MsgType
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a98020167777-7">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-v">
                  Content
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  !
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  CDATA
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-sy">
                  $
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  Content
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a98020167777-8">
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-o">
                  /
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a98020167777-9">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0057 seconds] -->
        </div>
        <p>
         然后编辑weixinInterface.py
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61a9f577810768" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            def POST(self): 
    str_xml = web.data() #获得post来的数据 
    xml = etree.fromstring(str_xml)#进行XML解析 
    msgType=xml.find("MsgType").text 
    fromUser=xml.find("FromUserName").text 
    toUser=xml.find("ToUserName").text 
    if msgType == 'text':
        content=xml.find("Content").text
        return self.render.reply_text(fromUser,toUser,int(time.time()), content)
    elif msgType == 'image':
        pass
    else:
        pass
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61a9f577810768-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a9f577810768-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a9f577810768-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a9f577810768-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a9f577810768-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a9f577810768-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a9f577810768-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a9f577810768-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a9f577810768-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a9f577810768-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a9f577810768-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a9f577810768-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61a9f577810768-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61a9f577810768-14">
                 14
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61a9f577810768-1">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  POST
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a9f577810768-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  data
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #获得post来的数据
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a9f577810768-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  etree
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  fromstring
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-p">
                  #进行XML解析
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a9f577810768-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "MsgType"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a9f577810768-5">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "FromUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a9f577810768-6">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "ToUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a9f577810768-7">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'text'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a9f577810768-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "Content"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a9f577810768-9">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a9f577810768-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  elif
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'image'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a9f577810768-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  pass
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a9f577810768-12">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  else
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61a9f577810768-13">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  pass
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61a9f577810768-14">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0191 seconds] -->
        </div>
        <p>
         以上操作的功能为：判断用户消息类型，如果消息类型为文本，则获取其内容content，并原样返回 content 作为消息。
        </p>
        <p>
         完成以上修改后，重复 git 操作将修改 push 到远程仓库即可。
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61aa5813456525" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            git add .
git commit -m 'your commit message'
git push sae master:1
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61aa5813456525-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aa5813456525-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aa5813456525-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aa5813456525-4">
                 4
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61aa5813456525-1">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-i">
                  add
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aa5813456525-2">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-v">
                  commit
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  -
                 </span>
                 <span class="crayon-i">
                  m
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'your commit message'
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aa5813456525-3">
                 <span class="crayon-e">
                  git
                 </span>
                 <span class="crayon-e">
                  push
                 </span>
                 <span class="crayon-e">
                  sae
                 </span>
                 <span class="crayon-v">
                  master
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aa5813456525-4">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0011 seconds] -->
        </div>
        <p>
         测试效果图：
        </p>
        <p>
         <img src="https://pic2.zhimg.com/911a742e8a1bcd3cc4c56a6735617e89_b.jpg"/>
         2.3 文本消息操作小例——查快递
        </p>
        <p>
         上一小节我们已经完成了对文本消息最基础的操作，但是原样返回内容，并没有做任何更多的操作，这一次我们来试试快递接口。
        </p>
        <p>
         我使用的依然是前文中提到的文章中的 kuaidi100 查快递接口，不过我在本地测试了许多次通过但是 SAE 的服务器依然无法返回正常结果，在网上搜了很久发现时 快递100 封掉了来自 SAE IP 段的请求，也就是说那个接口不能用了，那段代码也废掉了。所以我们只能退而求其次，做一个通过快递单号判断快递公司的功能。
        </p>
        <p>
         依然是修改weixinInterface.py
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61aac036682318" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            def POST(self): 
    str_xml = web.data() #获得post来的数据 
    xml = etree.fromstring(str_xml)#进行XML解析 
    msgType=xml.find("MsgType").text 
    fromUser=xml.find("FromUserName").text 
    toUser=xml.find("ToUserName").text 
    if msgType == 'text':
        content=xml.find("Content").text
        if content[0:2] == u"快递":
            post = str(content[2:])
            r = urllib2.urlopen('http://www.kuaidi100.com/autonumber/autoComNum?text='+post)
            h = r.read()
            k = eval(h)
            kuaidi = k["auto"][0]['comCode']
            return self.render.reply_text(fromUser,toUser,int(time.time()), kuaidi)
    elif msgType == 'image':
        pass
    else:
        pass
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-15">
                 15
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-16">
                 16
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-17">
                 17
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-18">
                 18
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61aac036682318-19">
                 19
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61aac036682318-20">
                 20
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61aac036682318-1">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  POST
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  data
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #获得post来的数据
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  etree
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  fromstring
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-p">
                  #进行XML解析
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "MsgType"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-5">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "FromUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-6">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "ToUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-7">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'text'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "Content"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-9">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  u
                 </span>
                 <span class="crayon-s">
                  "快递"
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  post
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  str
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  r
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  urllib2
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  urlopen
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  'http://www.kuaidi100.com/autonumber/autoComNum?text='
                 </span>
                 <span class="crayon-o">
                  +
                 </span>
                 <span class="crayon-v">
                  post
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  h
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  r
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  read
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-13">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  k
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  eval
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  h
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-14">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  kuaidi
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  k
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-s">
                  "auto"
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-s">
                  'comCode'
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-15">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  kuaidi
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-16">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  elif
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'image'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-17">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  pass
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-18">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  else
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61aac036682318-19">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  pass
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61aac036682318-20">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0128 seconds] -->
        </div>
        <p>
         上面的功能很简单，就是判断用户消息如果前两个字为快递，则取出后面的字符串作为快递单号，通过接口查询后返回结果发送给用户。重复 git 命令更新远程代码后测试效果图如下：
        </p>
        <p>
         <img src="https://pic2.zhimg.com/2b8bc15345c98cd09f8a6903fa0e9765_b.jpg"/>
         到此我们就完成了第一部分，服务器搭建和一些简单的文本消息操作。
        </p>
        <p>
         其实对于有一定编程能力的小伙伴来讲，捅破了这层窗户纸以后，其实就能根据自己以前的兴趣和经验做出许多自己喜欢的东西来了。Enjoy coding！
        </p>
        <h2>
         3. 曲径通幽处
        </h2>
        <p>
         上面完成对文本消息的一些基础操作后，我们可以尝试做一些更有趣的事情了。之前说到
         <a class="internal" href="https://zhuanlan.zhihu.com/p/21284127">
          Python公众号开发部分代码开源 – 学习编程 – 知乎专栏
         </a>
         中的源码在最开始就漏掉了 msgType 的判断，除此之外原作者还使用了极度过程化的写法和极度臃肿的代码结构，这一部分我们会尝试添加第三方的依赖包，尝试通过抽出函数方法来结构化代码，最后尝试对图片消息进行处理。
        </p>
        <p>
         3.1 添加第三方依赖包
        </p>
        <p>
         在上面的接口调用中，我们用到了 urllib2 库，但是熟悉 Python 爬虫的都知道，我们最常用到的其实是第三方的 requests 库，那么怎么把第三方库添加到 SAE 空间中呢？参阅了开发文档以后得到答案：
         <a class=" external" href="https://link.zhihu.com/?target=https%3A//www.sinacloud.com/doc/sae/python/tools.html%23tian-jia-di-san-fang-yi-lai-bao" rel="nofollow noreferrer" target="_blank">
          <span class="invisible">
           https://www.
          </span>
          <span class="visible">
           sinacloud.com/doc/sae/p
          </span>
          <span class="invisible">
           ython/tools.html#tian-jia-di-san-fang-yi-lai-bao
          </span>
          <i class="icon-external">
          </i>
         </a>
        </p>
        <p>
         具体做法不一定拘泥于官方给出的步骤，可以自己在本地仓库新建文件夹 vendor ，然后使用pip -t 选项指定第三方库安装地址，最后添加路径到 index.wsgi文件中。
        </p>
        <p>
         以安装 requests 为例。
        </p>
        <p>
         <img src="https://pic4.zhimg.com/72b9a9a76a31c78d44a7cc4ce462c283_b.png"/>
         之后编辑 index.wsgi，在顶部添加代码即可。
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61ab6641744647" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            # coding: UTF-8
import os
import sae
import web
sae.add_vendor_dir('vendor')
from weixinInterface import WeixinInterface
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61ab6641744647-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ab6641744647-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ab6641744647-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ab6641744647-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ab6641744647-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ab6641744647-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ab6641744647-7">
                 7
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61ab6641744647-1">
                 <span class="crayon-p">
                  # coding: UTF-8
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ab6641744647-2">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  os
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ab6641744647-3">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  sae
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ab6641744647-4">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  web
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ab6641744647-5">
                 <span class="crayon-v">
                  sae
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  add_vendor_dir
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  'vendor'
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ab6641744647-6">
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  weixinInterface
                 </span>
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-i">
                  WeixinInterface
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ab6641744647-7">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0013 seconds] -->
        </div>
        <p>
         有了这些第三方依赖库，我们就能更加轻松地实现需要的功能了。
        </p>
        <p>
         3.2 函数的结构化方法
        </p>
        <p>
         文本消息很多，我们如果不断地添加判断，作出一些操作并返回结果，代码势必变得极其臃肿，既不利于阅读，更不利于调试代码。于是我们尝试将之前已有的通过快递单号查询公司的代码改写为函数。
        </p>
        <p>
         新建 cxkd.py
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61ac2042963953" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            import urllib2
def detect_com(postid):
    r = urllib2.urlopen('http://www.kuaidi100.com/autonumber/autoComNum?text='+postid)
    h = r.read()
    k = eval(h)
    kuaiditpye = k["auto"][0]['comCode']
#print kuaiditpye
    return kuaiditpye
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61ac2042963953-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ac2042963953-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ac2042963953-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ac2042963953-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ac2042963953-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ac2042963953-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ac2042963953-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ac2042963953-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ac2042963953-9">
                 9
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61ac2042963953-1">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  urllib2
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ac2042963953-2">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  detect_com
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  postid
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ac2042963953-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  r
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  urllib2
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  urlopen
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  'http://www.kuaidi100.com/autonumber/autoComNum?text='
                 </span>
                 <span class="crayon-o">
                  +
                 </span>
                 <span class="crayon-v">
                  postid
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ac2042963953-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  h
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  r
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  read
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ac2042963953-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  k
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  eval
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  h
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ac2042963953-6">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  kuaiditpye
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  k
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-s">
                  "auto"
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-s">
                  'comCode'
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ac2042963953-7">
                 <span class="crayon-p">
                  #print kuaiditpye
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ac2042963953-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  kuaiditpye
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ac2042963953-9">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0091 seconds] -->
        </div>
        <p>
         修改 weixinInterface.py，导入 cxkd.py 并修改源代码。
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61ace319759264" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            import cxkd

def POST(self): 
    str_xml = web.data() #获得post来的数据 
    xml = etree.fromstring(str_xml)#进行XML解析 
    msgType=xml.find("MsgType").text 
    fromUser=xml.find("FromUserName").text 
    toUser=xml.find("ToUserName").text 
    if msgType == 'text':
        content=xml.find("Content").text
        if content[0:2] == u"快递":
            post = str(content[2:])
            kuaidi = cxkd.detect_com(post)
            return self.render.reply_text(fromUser,toUser,int(time.time()), kuaidi)
    elif msgType == 'image':
        pass
    else:
        pass
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-15">
                 15
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-16">
                 16
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-17">
                 17
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ace319759264-18">
                 18
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ace319759264-19">
                 19
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61ace319759264-1">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  cxkd
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-2">
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-3">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  POST
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  data
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #获得post来的数据
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  etree
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  fromstring
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-p">
                  #进行XML解析
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-6">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "MsgType"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-7">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "FromUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-8">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "ToUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-9">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'text'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "Content"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-11">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  u
                 </span>
                 <span class="crayon-s">
                  "快递"
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  post
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  str
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-13">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  kuaidi
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  cxkd
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  detect_com
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  post
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-14">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  kuaidi
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-15">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  elif
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'image'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-16">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  pass
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-17">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  else
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ace319759264-18">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  pass
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ace319759264-19">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0178 seconds] -->
        </div>
        <p>
         经过测试这种写法是可行的。显然代码量较大的情况下，这样的写法可以使代码更加简洁易懂，便于修改调试。
        </p>
        <p>
         3.3 旧瓶装新酒——再谈人脸识别
        </p>
        <p>
         在我很久一篇的专栏中（
         <a class="internal" href="https://zhuanlan.zhihu.com/p/20091394">
          Python 爬虫笔记（2）：插播——我也来做Facemash！ – 小段同学的杂记 – 知乎专栏
         </a>
         ）曾经提到过微软的 How-old.net 人脸识别的接口，当然那个接口是我自己通过抓包拿到的，那篇文章赞数寥寥，平时好像也没见谁拿那个接口实现过什么功能，这次想起来要处理图片消息，我第一个便又想起来那个接口。
        </p>
        <p>
         旧瓶装新酒，能饮一杯无。
        </p>
        <p>
         接口的详情可以到上文的链接中查看，这里直接给出代码好了。
        </p>
        <p>
         新建 imgtest.py
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61ada920402843" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            # -*- coding: utf-8 -*-
import requests
import re
def imgtest(picurl):
    s = requests.session()
    url = 'http://how-old.net/Home/Analyze?isTest=False&amp;amp;source=&amp;amp;version=001'
    header = {
'Accept-Encoding':'gzip, deflate',
    'User-Agent': "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:34.0) Gecko/20100101 Firefox/34.0",
    'Host': "how-old.net",
    'Referer': "http://how-old.net/",
    'X-Requested-With': "XMLHttpRequest"
        }

    data = {'file':s.get(picurl).content}
#data = {'file': open(sid+'.jpg', 'rb')}
     #此处打开指定的jpg文件

    r = s.post(url, files=data, headers=header)
    h = r.content
    i = h.replace('\\','')
#j = eval(i)

    gender = re.search(r'"gender": "(.*?)"rn', i)
    age = re.search(r'"age": (.*?),rn', i)
if gender.group(1) == 'Male':
        gender1 = '男'
    else:
        gender1 = '女'
    #print gender1
    #print age.group(1)
    datas = [gender1, age.group(1)]
return datas
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-15">
                 15
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-16">
                 16
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-17">
                 17
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-18">
                 18
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-19">
                 19
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-20">
                 20
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-21">
                 21
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-22">
                 22
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-23">
                 23
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-24">
                 24
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-25">
                 25
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-26">
                 26
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-27">
                 27
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-28">
                 28
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-29">
                 29
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-30">
                 30
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-31">
                 31
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-32">
                 32
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ada920402843-33">
                 33
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ada920402843-34">
                 34
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61ada920402843-1">
                 <span class="crayon-p">
                  # -*- coding: utf-8 -*-
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-2">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  requests
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-3">
                 <span class="crayon-e">
                  import
                 </span>
                 <span class="crayon-e">
                  re
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-4">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  imgtest
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  picurl
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  requests
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  session
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-6">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  url
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'http://how-old.net/Home/Analyze?isTest=False&amp;amp;source=&amp;amp;version=001'
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-7">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  header
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  {
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-8">
                 <span class="crayon-s">
                  'Accept-Encoding'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-s">
                  'gzip, deflate'
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-9">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'User-Agent'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:34.0) Gecko/20100101 Firefox/34.0"
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'Host'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  "how-old.net"
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'Referer'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  "http://how-old.net/"
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'X-Requested-With'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  "XMLHttpRequest"
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-13">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  }
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-14">
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-15">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  {
                 </span>
                 <span class="crayon-s">
                  'file'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  get
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  picurl
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  }
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-16">
                 <span class="crayon-p">
                  #data = {'file': open(sid+'.jpg', 'rb')}
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-17">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #此处打开指定的jpg文件
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-18">
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-19">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  r
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  post
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  url
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  files
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  data
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  headers
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  header
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-20">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  h
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  r
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-i">
                  content
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-21">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  i
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  h
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  replace
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  '\\'
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-s">
                  ''
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-22">
                 <span class="crayon-p">
                  #j = eval(i)
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-23">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-24">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  gender
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  re
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  search
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-i">
                  r
                 </span>
                 <span class="crayon-s">
                  '"gender": "(.*?)"rn'
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  i
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-25">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  re
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  search
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-i">
                  r
                 </span>
                 <span class="crayon-s">
                  '"age": (.*?),rn'
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  i
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-26">
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  gender
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  group
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'Male'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-27">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  gender1
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  '男'
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-28">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  else
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-29">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  gender1
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  '女'
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-30">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #print gender1
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-31">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #print age.group(1)
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-32">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  datas
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-v">
                  gender1
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  group
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ada920402843-33">
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  datas
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ada920402843-34">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0138 seconds] -->
        </div>
        <p>
         修改 weixinInterface.py
        </p>
        <div class="highlight">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768530f61ae5261383198" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            def POST(self):
    str_xml = web.data() #获得post来的数据
    xml = etree.fromstring(str_xml)#进行XML解析
    #content=xml.find("Content").text#获得用户所输入的内容
    msgType=xml.find("MsgType").text
    fromUser=xml.find("FromUserName").text
    toUser=xml.find("ToUserName").text
    if msgType == 'image':
try:
            picurl = xml.find('PicUrl').text
            datas = imgtest(picurl)
return self.render.reply_text(fromUser, toUser, int(time.time()), '图中人物性别为'+datas[0]+'\n'+'年龄为'+datas[1])
except:
return self.render.reply_text(fromUser, toUser, int(time.time()),  '识别失败，换张图片试试吧')
else:
        content = xml.find("Content").text  # 获得用户所输入的内容
        if content[0:2] == u"快递":
            post = str(content[2:])
            kuaidi = cxkd.detect_com(post)
            return self.render.reply_text(fromUser,toUser,int(time.time()), kuaidi)

else:
return self.render.reply_text(fromUser,toUser,int(time.time()), content)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-15">
                 15
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-16">
                 16
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-17">
                 17
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-18">
                 18
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-19">
                 19
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-20">
                 20
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-21">
                 21
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-22">
                 22
                </div>
                <div class="crayon-num" data-line="crayon-5768530f61ae5261383198-23">
                 23
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-5768530f61ae5261383198-24">
                 24
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-1">
                 <span class="crayon-e">
                  def
                 </span>
                 <span class="crayon-e">
                  POST
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  web
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  data
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #获得post来的数据
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  etree
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  fromstring
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  str_xml
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-p">
                  #进行XML解析
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  #content=xml.find("Content").text#获得用户所输入的内容
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "MsgType"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-6">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "FromUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-7">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "ToUserName"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-8">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  msgType
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  'image'
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-9">
                 <span class="crayon-st">
                  try
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  picurl
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  'PicUrl'
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  text
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-11">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  datas
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  imgtest
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  picurl
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-12">
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  '图中人物性别为'
                 </span>
                 <span class="crayon-o">
                  +
                 </span>
                 <span class="crayon-v">
                  datas
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-o">
                  +
                 </span>
                 <span class="crayon-s">
                  '\n'
                 </span>
                 <span class="crayon-o">
                  +
                 </span>
                 <span class="crayon-s">
                  '年龄为'
                 </span>
                 <span class="crayon-o">
                  +
                 </span>
                 <span class="crayon-v">
                  datas
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-13">
                 <span class="crayon-v">
                  except
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-14">
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-s">
                  '识别失败，换张图片试试吧'
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-15">
                 <span class="crayon-st">
                  else
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-16">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  xml
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  find
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-s">
                  "Content"
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  text
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-p">
                  # 获得用户所输入的内容
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-17">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  if
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  ==
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  u
                 </span>
                 <span class="crayon-s">
                  "快递"
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-18">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  post
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  str
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  [
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                 <span class="crayon-sy">
                  ]
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-19">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  kuaidi
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  cxkd
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  detect_com
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  post
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-20">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  kuaidi
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-21">
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-22">
                 <span class="crayon-st">
                  else
                 </span>
                 <span class="crayon-o">
                  :
                 </span>
                </div>
                <div class="crayon-line" id="crayon-5768530f61ae5261383198-23">
                 <span class="crayon-st">
                  return
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-r">
                  self
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  render
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  reply_text
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  fromUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  toUser
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  time
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  time
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  content
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-5768530f61ae5261383198-24">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0211 seconds] -->
        </div>
        <p>
         然后 git 提交到远程仓库。测试如下：
        </p>
        <p>
         <img src="https://pic4.zhimg.com/ead2c40dadf40c79f07ffe171266bb0b_b.jpg"/>
        </p>
        <h2>
         4. 鱼香肉丝盖饭
        </h2>
        <p>
         You share rose get fun.
        </p>
        <p>
         以前也有舍友问我说，你说你为什么要在网上帮别人完一些任务，你这是在害他们啊。
        </p>
        <p>
         我说并没有啊，我写
         <a class="internal" href="https://www.zhihu.com/question/29979949/answer/49553763">
          如何用Python写一个抓取新浪财经网指定企业年报的脚本？ – 知乎用户的回答
         </a>
         时的结果都是空的，写
         <a class="internal" href="https://www.zhihu.com/question/41136540/answer/89765276">
          如何用爬虫下载武汉市环保局空气污染数据？ – 知乎用户的回答
         </a>
         的时候只给了几个月的结果。其实教学相长，我自己是一个学习的过程，如果能顺便帮到别人，自然是好事啊。
        </p>
        <p>
         分享是一种很可贵的东西吧。以前的知乎很好，我也不去评价现在的知乎了。但是我还是愿意分享一些东西出来，虽然可能原创的成分不高，可能都是拼拼凑凑，也可能水平很低，但是都是我学习的一些经历吧，如果能让别人少走一些弯路，或者激起别人的兴趣，都是很功德的事情。
        </p>
        <p>
         想了想还是把这次的所有代码贴到 Github 了，平时也不怎么用 Github ，不过怕知乎的编辑器复制粘贴给大家带来麻烦。
        </p>
        <p>
         <a class=" wrap external" href="https://link.zhihu.com/?target=https%3A//github.com/loveQt/wxpytest" rel="nofollow noreferrer" target="_blank">
          GitHub – loveQt/wxpytest
          <i class="icon-external">
          </i>
         </a>
        </p>
        <p>
         也可以看出来这次的所有文档结构：（Chrome插件 Octotree）
        </p>
        <p>
         <img src="https://pic2.zhimg.com/5c0e92f87589b5e12ea2cedda593daf1_b.png"/>
         <br/>
         最后留一下这次开发中用到的公众号（鱼香肉丝盖饭 rose-fun），算是我的个人公众号，做着玩儿的，关不关注无所谓，因为平时也不怎么写东西推东西。源代码已经贴出来了，照着文章几分钟能搭出来一个一模一样的。
        </p>
        <p>
         现在的功能就三块，更多的东西还没加：
        </p>
        <p>
         1、回复 快递xxxxxx 自动识别快递公司
        </p>
        <p>
         2、发送图片 识别性别和年龄
        </p>
        <p>
         3、其他文字信息 原样返回
        </p>
        <p>
         <a class=" external" href="https://link.zhihu.com/?target=http%3A//weixin.qq.com/r/MDqnv3PEsy7MrTfc928i" rel="nofollow noreferrer" target="_blank">
          <span class="invisible">
           http://
          </span>
          <span class="visible">
           weixin.qq.com/r/MDqnv3P
          </span>
          <span class="invisible">
           Esy7MrTfc928i
          </span>
          <i class="icon-external">
          </i>
         </a>
         (二维码自动识别)
         <br/>
         知乎加了二维码自动识别…
        </p>
        <p>
         <img src="https://pic1.zhimg.com/415681b0c2dbfa0557e7daa7d41761f0_b.jpg"/>
         To-dos：
        </p>
        <p>
         配置 SAE 本地开发环境。因为 push 一次在线调试一次太麻烦了。
        </p>
        <p>
         完善开发公众号其他功能。
        </p>
        <p>
         （当然按照我这爱跳票的性子不知道到什么时候了…）
         <br/>
         文章参考了许多网上的文章，和一些别人的源码，多数原始出处不可考证，只贴出我所参考的链接。
        </p>
        <p>
         <a class=" external" href="https://link.zhihu.com/?target=http%3A//my.oschina.net/yangyanxing/blog/159215" rel="nofollow noreferrer" target="_blank">
          <span class="invisible">
           http://
          </span>
          <span class="visible">
           my.oschina.net/yangyanx
          </span>
          <span class="invisible">
           ing/blog/159215
          </span>
          <i class="icon-external">
          </i>
         </a>
        </p>
        <p>
         <a class="internal" href="https://zhuanlan.zhihu.com/p/21284127">
          Python公众号开发部分代码开源 – 学习编程 – 知乎专栏
         </a>
        </p>
        <p>
         <a class="internal" href="https://zhuanlan.zhihu.com/p/20091394">
          Python 爬虫笔记（2）：插播——我也来做Facemash！ – 小段同学的杂记 – 知乎专栏
         </a>
        </p>
        <p>
         晚安。
        </p>
       </div>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24678.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/20140917125452915416-216x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24678.html" rel="bookmark" title="python3中的正则模块">
         python3中的正则模块
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24675.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/t015b337bd75d9ef893-161x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24675.html" rel="bookmark" title="注释是恶魔，请不要再写一行注释">
         注释是恶魔，请不要再写一行注释
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24660.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/u16130037972892789947fm21gp0-300x157.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24660.html" rel="bookmark" title="如何从Github上轻松安装R包">
         如何从Github上轻松安装R包
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24654.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/df53fac99fc53ba5a90666abcca25e6d_b-267x200.png"/>
        </a>
        <a class="link" href="http://dataunion.org/24654.html" rel="bookmark" title="简单形象又有趣地说说强大的神经网络">
         简单形象又有趣地说说强大的神经网络
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F24635.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/24635.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/24635.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>